package com.mspbots.teams.controller;

import com.mspbots.teams.schedule.NoReceivedUserSchedule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

@Slf4j
@RestController
@RequestMapping("teams/no-message/user")
public class NoMessageUserController {

    @Autowired
    private NoReceivedUserSchedule noReceivedUserSchedule;

    @GetMapping("check")
    public Callable check(@RequestParam(required = false) Integer tenantId) {
        return () -> {
            try {
                noReceivedUserSchedule.checkNoReceivedTeamsUser(tenantId);
            } catch (Exception e) {
                log.error(e.getMessage());
                return false;
            }
            return true;
        };
    }
}
